package com.zkthink.ceres.msgs.controller;

import com.zkthink.base.R;
import com.zkthink.ceres.info.dto.PlatformInfoDTO;
import com.zkthink.ceres.info.entity.PlatformInfo;
import com.zkthink.ceres.msgs.service.PlatformInfoService;
import com.zkthink.dozer.DozerUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * 平台信息
 * </p>
 *
 * @date 2020-12-30
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/platformInfo")
@Api(value = "platformInfo", tags = "平台信息")
@AllArgsConstructor
public class PlatformInfoController {

    private DozerUtils dozerUtils;

    @Autowired
    private PlatformInfoService platformInfoService;

    @ApiOperation(value = "查询平台信息", notes = "查询平台信息")
    @PostMapping("/select")
    public R<PlatformInfoDTO> findPlatformInfo() {
        PlatformInfo platformInfo = platformInfoService.findPlatformInfo();
        PlatformInfoDTO platformInfoDTO = dozerUtils.map(platformInfo, PlatformInfoDTO.class);
        return R.success(platformInfoDTO);
    }

    @ApiOperation(value = "添加平台信息", notes = "添加平台信息")
    @PostMapping("/add")
    public R<Boolean> addPlatformInfo(@RequestBody PlatformInfo dto) {
        return platformInfoService.addPlatformInfo(dto);
    }
}
